#include <fcntl.h>
#include <unistd.h>
#include <stdio.h>
#include <string.h>

/*
* ./button_test /dev/rk3399_button0
*
*/
int main(int argc, char **argv)
{
    int fd;
    char val;

    /* 1. 判断参数 */
    if (argc != 2)
    {
        printf("Usage : %s <dev>\n", argv[0]);
        return -1;
    }

    /* 2. 打开文件 */
    fd = open(argv[1], O_RDWR);
    if (fd == -1)
    {
        printf("can not open file %s\n", argv[1]);
        return -1;
    }

    /* 3. 写文件 */
    read(fd, &val, 1);
    printf("get button : %d\n", val);

    close(fd);

    return 0;
}